'''
# 作者    ： 张莹潇
# 创建时间 ： 20/12/12 18:19
'''
from app.cta_strategy.backtesting import BacktestingEngine, OptimizationSetting
from app.cta_strategy.strategies.smooth_degree_strategy import (
    SmoothDegreeStrategy
)
from app.cta_strategy.strategies.double_ma_strategy import (
    DoubleMaStrategy
)
from datetime import datetime

engine = BacktestingEngine()
engine.set_parameters(
    vt_symbol="IF2012.CFFEX",
    interval="1m",
    start=datetime(2010, 1, 1),
    end=datetime(2019, 4, 30),
    rate=0.3/10000,
    slippage=0.2,
    size=300,
    pricetick=0.2,
    capital=1_000_000,
)
# engine.add_strategy(DoubleMaStrategy, {})
engine.add_strategy(SmoothDegreeStrategy, {})
engine.load_data()
engine.run_backtesting()
df = engine.calculate_result()
engine.calculate_statistics()
engine.show_chart()

# setting = OptimizationSetting()
# setting.set_target("sharpe_ratio")
# setting.add_parameter("atr_length", 3, 39, 1)
# setting.add_parameter("atr_ma_length", 10, 30, 1)
#
# engine.run_ga_optimization(setting)